#include"syscall.h"
#include"print.c"

void main(){

	int lock;
	int cv;
	int mv;
	int value;
	int test[2];

	printString("========================create and destroy lock, cv, mv============================\n");
	lock = CreateLock("lock1",5);
	printf("Create lock %d\n",&lock);
	cv = CreateCondition("cv1",3);
	printf("Create cv %d\n",&cv);
	mv = CreateMVN("mv1",3,5);
	printf("Create MV %d\n",&mv);
	
	DestroyLock(lock);
	printf("Destroy lock %d\n",&lock);
	DestroyCondition(cv);
	printf("Destroy cv %d\n",&cv);
	DestroyMVN(mv);
	printf("Destroy mv %d\n",&mv);
	printString("\n");

	test[0]=cv;
	test[1]=lock;
	
	printString("==========================use inexistent lock,cv,mv===============================\n");
	printf("Acquire lock %d\n",&lock);
	Acquire(lock);
	printf("Release lock %d\n",&lock);
	Release(cv);
	printf("Wait cv %d with lock %d\n",test);
	Wait(cv,lock);
	printf("Signal cv %d with lock %d\n",test);
	Signal(cv,lock);
	printf("Broadcast cv %d with lock %d\n",test);
	Broadcast(cv,lock);
	printf("set mv %d.\n", &mv);
	SetMV(mv,0,100);
	printf("Get mv %d.\n", &mv);
	value = GetMV(mv,0);

	printf("Destroy lock %d\n",&lock);
	DestroyLock(lock);
	printf("Destroy cv %d\n",&cv);
	DestroyCondition(cv);
	printf("Destroy mv %d\n",&mv);
	DestroyMVN(mv);
	
	StopServer();
	Exit(0);

}
